package cn.sciento.boot.tenant.aspect.aop;

import java.lang.reflect.Method;
import java.util.Objects;
import org.springframework.aop.support.StaticMethodMatcherPointcut;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

@Component
public class TenantCreatePointcut extends StaticMethodMatcherPointcut {
  private static final String TENANT_COMMON_CLASS_NAME = "cn.sciento.iam.domain.service.impl.TenantCommonServiceImpl";
  
  private static final String TENANT_CREATE_METHOD_NAME = "createTenant";
  
  @Override
  public boolean matches(Method method, @Nullable Class<?> targetClass) {
    return (targetClass.getName().equals(TENANT_COMMON_CLASS_NAME) && Objects.equals(method.getName(), "createTenant"));
  }
}
